import matplotlib.pyplot as plt

# 读取CSV文件
import pandas as pd
df = pd.read_csv('bilibili_videos.csv', encoding='utf-8')

# 选取前20条数据
top_20 = df.head(20)

# 绘制投币数的柱状图
plt.rcParams['font.sans-serif']=['SimHei']
plt.figure(figsize=(10, 6))
plt.bar(top_20['标题'], top_20['播放量'], color='skyblue')
plt.xlabel('视频标题')
plt.ylabel('播放量')
plt.title('Top 20 Videos by Coins')
plt.xticks(rotation=90)
plt.tight_layout()
plt.show()
